package com.ruoyi.performance.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.performance.domain.ScoreSummary;
import com.ruoyi.performance.service.IScoreSummaryService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 分数汇总Controller
 * 
 * @author ruoyi
 * @date 2024-03-24
 */
@RestController
@RequestMapping("/scoreSummary")
public class ScoreSummaryController extends BaseController
{
    @Autowired
    private IScoreSummaryService scoreSummaryService;



    /**
     * 修改分数汇总
     */
    @PostMapping("/updatesm")
    public void updatesm(@RequestBody ScoreSummary scoreSummary)
    {
        scoreSummaryService.updatesm(scoreSummary);
    }

    /**
     * 查询分数汇总列表
     */
    @RequiresPermissions("performance:scoreSummary:list")
    @GetMapping("/list")
    public TableDataInfo list(ScoreSummary scoreSummary)
    {
        startPage();
        List<ScoreSummary> list = scoreSummaryService.selectScoreSummaryList(scoreSummary);
        return getDataTable(list);
    }

    /**
     * 导出分数汇总列表
     */
    @RequiresPermissions("performance:scoreSummary:export")
    @Log(title = "分数汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScoreSummary scoreSummary)
    {
        List<ScoreSummary> list = scoreSummaryService.selectScoreSummaryList(scoreSummary);
        ExcelUtil<ScoreSummary> util = new ExcelUtil<ScoreSummary>(ScoreSummary.class);
        util.exportExcel(response, list, "分数汇总数据");
    }

    /**
     * 获取分数汇总详细信息
     */
    @RequiresPermissions("performance:scoreSummary:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(scoreSummaryService.selectScoreSummaryById(id));
    }

    /**
     * 新增分数汇总
     */
    @RequiresPermissions("performance:scoreSummary:add")
    @Log(title = "分数汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScoreSummary scoreSummary)
    {
        return toAjax(scoreSummaryService.insertScoreSummary(scoreSummary));
    }

    /**
     * 修改分数汇总
     */
    @RequiresPermissions("performance:scoreSummary:edit")
    @Log(title = "分数汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScoreSummary scoreSummary)
    {
        return toAjax(scoreSummaryService.updateScoreSummary(scoreSummary));
    }

    /**
     * 删除分数汇总
     */
    @RequiresPermissions("performance:scoreSummary:remove")
    @Log(title = "分数汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scoreSummaryService.deleteScoreSummaryByIds(ids));
    }
}
